﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DHQGHN.PM0.Common.Attributes;
using DHQGHN.PM0.Controllers.Admin;

namespace DHQGHN.PM0.Models.Admin
{
    public class GroupInRoleModel
    {
        #region Property of Group in Role Model
        public int GroupInRoleID { get; set; }
        [Remote("CheckExistGroupInRole", "GroupInRole", ErrorMessage = "Nhóm đã tồn tại trong vai trò", HttpMethod = "POST", AdditionalFields = "RoleID")]
        [Range(1, Int64.MaxValue, ErrorMessage = "Bạn cần chọn nhóm người dùng")]
        [Display(Name = "Nhóm người dùng")]
        public int GroupID { get; set; }

        public int AppID { get; set; }
        public string AppName { get; set; }

        [Range(1, Int64.MaxValue, ErrorMessage = "Bạn cần chọn vai trò")]
        [Display(Name = "Vai trò")]
        public int RoleID { get; set; }

        [StringLength(150, ErrorMessage = "Độ dài tối đa là 150 ký tự")]
        [Display(Name = "Mô tả")]
        public string Descriptions { get; set; }

        public int DateCreated { get; set; }
        public int DateModified { get; set; }
        public int IsActive { get; set; }
        public int RecordCount { get; set; }
        public string RoleName { get; set; }
        public string GroupName { get; set; }
        public string GroupCode { get; set; }
        #endregion

        #region List field in database
        public const string FIELD_APP_NAME = "AppName";
        public const string FIELD_GROUP_IN_ROLE_ID = "GroupInRoleID";
        public const string FIELD_GROUP_ID = "GroupID";
        public const string FIELD_ROLE_ID = "RoleId";
        public const string FIELD_DESCRIPTIONS = "Descriptions";
        public const string FIELD_IS_ACTIVE = "IsActive";
        public const string FIELD_DATE_CREATED = "DateCreated";
        public const string FIELD_DATE_MODIFIED = "DateModified";
        public const string FIELD_RECORD_COUNT = "RecordCount";
        public const string FIELD_ROLE_NAME = "RoleName";
        public const string FIELD_GROUP_NAME = "GroupName";
        public const string FIELD_GROUP_CODE = "GroupCode";
        #endregion

        public GroupInRoleModel(DAL.Models.Admin.GroupInRoleModel model)
        {
            // TODO: Complete member initialization
            AppID = model.AppID;
            AppName = model.AppName;
            GroupInRoleID = model.GroupInRoleID;
            GroupID = model.GroupID;
            RoleID = model.RoleID;
            Descriptions = model.Descriptions;
            IsActive = model.IsActive;
            DateCreated = model.DateCreated;
            DateModified = model.DateModified;
            RoleName = model.RoleName;
            GroupName = model.GroupName;
            GroupCode = model.GroupCode;
            RecordCount = model.RecordCount;
        }

        public GroupInRoleModel()
        {
            // TODO: Complete member initialization
        }

        internal DAL.Models.Admin.GroupInRoleModel toDALModel()
        {
            return new DAL.Models.Admin.GroupInRoleModel()
            {
                AppName = AppName,
                AppID = AppID,
                DateModified = DateModified,
                DateCreated = DateCreated,
                Descriptions = Descriptions,
                GroupCode = GroupCode,
                GroupName = GroupName,
                GroupInRoleID = GroupInRoleID,
                GroupID = GroupID,
                IsActive = IsActive,
                RoleName = RoleName,
                RoleID = RoleID,
                RecordCount = RecordCount
            };
        }
    }
}